package www.dashu.com.domain;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.Formula;
import www.dashu.com.domain.base.BaseVo;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

@Data
@Entity
@Table(name="oms_order")
public class OmsOrder extends BaseVo implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("订单id")
    @Id
    private Long id;

    @ApiModelProperty("")
    @Column(name = "u_id")
    private Long uId;

    @ApiModelProperty("")
    @Column(name = "coupon_id")
    private Long couponId;

    @ApiModelProperty("订单总金额")
    @Column(name = "total_amount")
    private Double totalAmount;

    @ApiModelProperty("应付金额（实际支付金额）")
    @Column(name = "pay_amount")
    private Double payAmount;

    @ApiModelProperty("运费金额")
    @Column(name = "freight_amount")
    private Double freightAmount;

    @ApiModelProperty("促销优化金额（促销价、满减、阶梯价）")
    @Column(name = "promotion_amount")
    private Double promotionAmount;

    @ApiModelProperty("积分抵扣金额")
    @Column(name = "integration_amount")
    private Double integrationAmount;

    @ApiModelProperty("优惠券抵扣金额")
    @Column(name = "coupon_amount")
    private Double couponAmount;

    @ApiModelProperty("管理员后台调整订单使用的折扣金额")
    @Column(name = "discount_amount")
    private Double discountAmount;

    @ApiModelProperty("支付方式：0->未支付；1->支付宝；2->微信")
    @Column(name = "pay_type")
    private Integer payType;

    @ApiModelProperty("订单来源：0->PC订单；1->app订单")
    @Column(name = "source_type")
    private Integer sourceType;

    @ApiModelProperty("订单状态：0->待付款；1->待发货；2->已发货；3->已完成；4->已关闭；5->无效订单")
    @Column(name = "status")
    private Integer status;

    @ApiModelProperty("订单类型：0->正常订单；1->秒杀订单")
    @Column(name = "order_type")
    private Integer orderType;

    @ApiModelProperty("物流公司(配送方式)")
    @Column(name = "delivery_company")
    private String deliveryCompany;

    @ApiModelProperty("物流单号")
    @Column(name = "delivery_sn")
    private String deliverySn;

    @ApiModelProperty("自动确认时间（天）")
    @Column(name = "auto_confirm_day")
    private Integer autoConfirmDay;

    @ApiModelProperty("可以获得的积分")
    @Column(name = "integration")
    private Integer integration;

    @ApiModelProperty("可以活动的成长值")
    @Column(name = "growth")
    private Integer growth;

    @ApiModelProperty("活动信息")
    @Column(name = "promotion_info")
    private String promotionInfo;

    @ApiModelProperty("发票类型：0->不开发票；1->电子发票；2->纸质发票")
    @Column(name = "bill_type")
    private Integer billType;

    @ApiModelProperty("发票抬头")
    @Column(name = "bill_header")
    private String billHeader;

    @ApiModelProperty("发票内容")
    @Column(name = "bill_content")
    private String billContent;

    @ApiModelProperty("收票人电话")
    @Column(name = "bill_receiver_phone")
    private String billReceiverPhone;

    @ApiModelProperty("收票人邮箱")
    @Column(name = "bill_receiver_email")
    private String billReceiverEmail;

    @ApiModelProperty("收货人姓名")
    @Column(name = "receiver_name")
    private String receiverName;

    @ApiModelProperty("收货人电话")
    @Column(name = "receiver_phone")
    private String receiverPhone;

    @ApiModelProperty("收货人邮编")
    @Column(name = "receiver_post_code")
    private String receiverPostCode;

    @ApiModelProperty("省份/直辖市")
    @Column(name = "receiver_province")
    private String receiverProvince;

    @ApiModelProperty("城市")
    @Column(name = "receiver_city")
    private String receiverCity;

    @ApiModelProperty("区")
    @Column(name = "receiver_region")
    private String receiverRegion;

    @ApiModelProperty("详细地址")
    @Column(name = "receiver_detail_address")
    private String receiverDetailAddress;

    @ApiModelProperty("订单备注")
    @Column(name = "note")
    private String note;

    @ApiModelProperty("确认收货状态：0->未确认；1->已确认")
    @Column(name = "confirm_status")
    private Integer confirmStatus;

    @ApiModelProperty("删除状态：0->未删除；1->已删除")
    @Column(name = "delete_status")
    private Integer deleteStatus;

    @ApiModelProperty("下单时使用的积分")
    @Column(name = "use_integration")
    private Integer useIntegration;

    @ApiModelProperty("支付时间")
    @Column(name = "payment_time")
    private Date paymentTime;

    @ApiModelProperty("发货时间")
    @Column(name = "delivery_time")
    private Date deliveryTime;

    @ApiModelProperty("确认收货时间")
    @Column(name = "receive_time")
    private Date receiveTime;

    @ApiModelProperty("评价时间")
    @Column(name = "comment_time")
    private Date commentTime;

    @ApiModelProperty("所属商户")
    @Formula("(select s.name from sys_company s where s.id = company )")
    private String companyName;

    @Column(name = "company")
    private Long company;

    @ApiModelProperty("所属应用")
    @Formula("(select s.name from sys_app s where s.id = app_id )")
    private String appName;

    @Column(name = "app_id")
    private Long appId;

    @ApiModelProperty("创建时间")
    @Column(name = "create_time")
    private Date createTime;

    @ApiModelProperty("更新时间")
    @Column(name = "update_time")
    private Date updateTime;


    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", uId=").append(uId);
        sb.append(", couponId=").append(couponId);
        sb.append(", totalAmount=").append(totalAmount);
        sb.append(", payAmount=").append(payAmount);
        sb.append(", freightAmount=").append(freightAmount);
        sb.append(", promotionAmount=").append(promotionAmount);
        sb.append(", integrationAmount=").append(integrationAmount);
        sb.append(", couponAmount=").append(couponAmount);
        sb.append(", discountAmount=").append(discountAmount);
        sb.append(", payType=").append(payType);
        sb.append(", sourceType=").append(sourceType);
        sb.append(", status=").append(status);
        sb.append(", orderType=").append(orderType);
        sb.append(", deliveryCompany=").append(deliveryCompany);
        sb.append(", deliverySn=").append(deliverySn);
        sb.append(", autoConfirmDay=").append(autoConfirmDay);
        sb.append(", integration=").append(integration);
        sb.append(", growth=").append(growth);
        sb.append(", promotionInfo=").append(promotionInfo);
        sb.append(", billType=").append(billType);
        sb.append(", billHeader=").append(billHeader);
        sb.append(", billContent=").append(billContent);
        sb.append(", billReceiverPhone=").append(billReceiverPhone);
        sb.append(", billReceiverEmail=").append(billReceiverEmail);
        sb.append(", receiverName=").append(receiverName);
        sb.append(", receiverPhone=").append(receiverPhone);
        sb.append(", receiverPostCode=").append(receiverPostCode);
        sb.append(", receiverProvince=").append(receiverProvince);
        sb.append(", receiverCity=").append(receiverCity);
        sb.append(", receiverRegion=").append(receiverRegion);
        sb.append(", receiverDetailAddress=").append(receiverDetailAddress);
        sb.append(", note=").append(note);
        sb.append(", confirmStatus=").append(confirmStatus);
        sb.append(", deleteStatus=").append(deleteStatus);
        sb.append(", useIntegration=").append(useIntegration);
        sb.append(", paymentTime=").append(paymentTime);
        sb.append(", deliveryTime=").append(deliveryTime);
        sb.append(", receiveTime=").append(receiveTime);
        sb.append(", commentTime=").append(commentTime);
        sb.append(", company=").append(company);
        sb.append(", appId=").append(appId);
        sb.append(", createTime=").append(createTime);
        sb.append(", updateTime=").append(updateTime);
        sb.append("]");
        return sb.toString();
    }

}